//
//  LYQMineNewAlertCell.m
//  ZCProject
//
//  Created by Zheng on 16/11/18.
//  Copyright © 2016年 Zheng. All rights reserved.
//

#import "LYQMineNewAlertCell.h"

#define kNotificationState [UIApplication sharedApplication].isRegisteredForRemoteNotifications

@implementation LYQMineNewAlertCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
        self.textLabel.font = kWFont(15);
        self.textLabel.textColor = kHexadecimal(@"666666");
        
        [self.contentView addSubview:self.alertStatusLbl];
        [self.contentView addSubview:self.statusSwitch];
        
        [self layoutSubviewsInContentView];
    }
    return self;
}


#pragma mark - layout subviews 
- (void)layoutSubviewsInContentView {
    
    [_alertStatusLbl mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-kWScale(12));
        make.centerY.equalTo(self);
    }];
    
    [_statusSwitch mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-kWScale(12));
        make.centerY.equalTo(self);
    }];
    
}

#pragma mark - load subviews
- (UILabel *)alertStatusLbl {
    if (!_alertStatusLbl) {
        _alertStatusLbl = [[UILabel alloc] init];
        _alertStatusLbl.font = kWFont(15);
        _alertStatusLbl.textColor = kLYQBlue;
        
        if (kNotificationState) {
            _alertStatusLbl.text = @"已开启";
        } else {
            _alertStatusLbl.text = @"已关闭";
        }
        
    }
    return _alertStatusLbl;
}

- (UISwitch *)statusSwitch {
    if (!_statusSwitch) {
        _statusSwitch = [[UISwitch alloc] init];
        _statusSwitch.onTintColor = kLYQBlue;
        [_statusSwitch addTarget:self action:@selector(statusSwtichAction:) forControlEvents:UIControlEventValueChanged];
    }
    return _statusSwitch;
}

#pragma mark - switch action
- (void)statusSwtichAction:(UISwitch *)sender {
    
}


@end
